package com.ruoyi.zxjd.work.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable4;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable4Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 纪检监察干部违纪违法案件情况Controller
 * 
 * @author lcc
 * @date 2021-02-26
 */
@Controller
@RequestMapping("/work/templatetable4")
public class WorkTemplateTable4Controller extends BaseController
{
    private String prefix = "work/templatetable4";

    @Autowired
    private IWorkTemplateTable4Service workTemplateTable4Service;

    @RequiresPermissions("work:templatetable4:view")
    @GetMapping()
    public String templatetable4()
    {
        return prefix + "/templatetable4";
    }

    /**
     * 查询纪检监察干部违纪违法案件情况列表
     */
    @RequiresPermissions("work:templatetable4:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkTemplateTable4 workTemplateTable4)
    {
        startPage();
        List<WorkTemplateTable4> list = workTemplateTable4Service.selectWorkTemplateTable4List(workTemplateTable4);
        return getDataTable(list);
    }

    /**
     * 导出纪检监察干部违纪违法案件情况列表
     */
    @RequiresPermissions("work:templatetable4:export")
    @Log(title = "纪检监察干部违纪违法案件情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WorkTemplateTable4 workTemplateTable4)
    {
        List<WorkTemplateTable4> list = workTemplateTable4Service.selectWorkTemplateTable4List(workTemplateTable4);
        ExcelUtil<WorkTemplateTable4> util = new ExcelUtil<WorkTemplateTable4>(WorkTemplateTable4.class);
        return util.exportExcel(list, "templatetable4");
    }

    /**
     * 新增纪检监察干部违纪违法案件情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存纪检监察干部违纪违法案件情况
     */
    @RequiresPermissions("work:templatetable4:add")
    @Log(title = "纪检监察干部违纪违法案件情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkProgressBO workProgressBO)
    {
        return toAjax(workTemplateTable4Service.insertWorkTemplateTable4(workProgressBO));
    }

    /**
     * 修改纪检监察干部违纪违法案件情况
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WorkTemplateTable4 workTemplateTable4 = workTemplateTable4Service.selectWorkTemplateTable4ById(id);
        mmap.put("workTemplateTable4", workTemplateTable4);
        return prefix + "/edit";
    }

    /**
     * 修改保存纪检监察干部违纪违法案件情况
     */
    @RequiresPermissions("work:templatetable4:edit")
    @Log(title = "纪检监察干部违纪违法案件情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkTemplateTable4 workTemplateTable4)
    {
        return toAjax(workTemplateTable4Service.updateWorkTemplateTable4(workTemplateTable4));
    }

    /**
     * 删除纪检监察干部违纪违法案件情况
     */
    @RequiresPermissions("work:templatetable4:remove")
    @Log(title = "纪检监察干部违纪违法案件情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(workTemplateTable4Service.deleteWorkTemplateTable4ByIds(ids));
    }
}
